<?php
// Shadow creation //

require_once('lib_load.php');
load_lib(array('DbMysql', 'User'));

$user = new User();

$user->Refresh(); //security check



if (isset($_POST['Shad_send']))
{

    if ($db->IsExist('player', 'name = \''.mysql_real_escape_string($_POST['Shad_name']).'\''))
        die('Name is already taken, please, choose another one');

    $db->AddLine('player', array('id' => NULL,
                                'name' => mysql_real_escape_string($_POST['Shad_name']),
                                'user' => $user->GetLogin(),
                                'mapname' => 'Academy',
                                'xcoor' => 9,
                                'ycoor' => 9,
                                'direction' => 0,
                                'mov' => 2
                                ));

    die('Shadow is successfuly added to your account. <a href="shadows.php">back</a>');
}
else
{

    // Loadfing the infomation in main_buffer
    $main_buf = implode('',file('templates/index.htm'));
    $reg_buf = implode('',file('templates/data/shadow/create.htm'));
    $main_buf=str_replace("[%INFO%]",$reg_buf ,$main_buf);

    // main info output
    echo $main_buf;
}


?>
